import requests
from lxml import etree
url ='https://comment.bilibili.com/189151011.xml'
headers = {'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36 Edg/88.0.705.56'}
r = requests.get(url = url, headers = headers).content#这里是content不是text（我说怎么爬不出来）
tree = etree.HTML(r)
d_list = tree.xpath('//d')
file = open('B站弹幕爬取.text','w',encoding='utf-8')
for d in d_list:
    title = d.xpath('./text()')[0]
    print(title)
    file.write(title+'/n')
